package com.youbug.mall.ware_wms.service.impl;

import com.youbug.mall.ware_wms.entity.WmsWareOrderTaskDetail;
import com.youbug.mall.ware_wms.mapper.WmsWareOrderTaskDetailMapper;
import com.youbug.mall.ware_wms.service.IWmsWareOrderTaskDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.youbug.mall.ware_wms.entity.WmsWareOrderTaskDetail;
import org.springframework.util.ObjectUtils;
import com.youbug.common.vo.QueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;

/**
 * <p>
 * 库存工作单 服务实现类
 * </p>
 *
 * @author youbug
 * @since 2024-07-14
 */
@Service
public class WmsWareOrderTaskDetailServiceImpl extends ServiceImpl<WmsWareOrderTaskDetailMapper, WmsWareOrderTaskDetail> implements IWmsWareOrderTaskDetailService {

        @Override
        public IPage<WmsWareOrderTaskDetail> getWmsWareOrderTaskDetailPage(QueryVo<WmsWareOrderTaskDetail> queryVo) {

        Page<WmsWareOrderTaskDetail> paramPage = new Page<>();

        paramPage.setCurrent(queryVo.getCurrentPage());

        paramPage.setSize(queryVo.getPageSize());

        QueryWrapper<WmsWareOrderTaskDetail> wrapper = new QueryWrapper<>();

        WmsWareOrderTaskDetail wmsWareOrderTaskDetail = queryVo.getPayload();

        if(!ObjectUtils.isEmpty(wmsWareOrderTaskDetail)){
                    if(wmsWareOrderTaskDetail.getId()!=null){
                    wrapper.gt("id", wmsWareOrderTaskDetail.getId());
                    }
                    if(wmsWareOrderTaskDetail.getSkuId()!=null){
                    wrapper.gt("sku_id", wmsWareOrderTaskDetail.getSkuId());
                    }
            if(StringUtils.hasText(wmsWareOrderTaskDetail.getSkuName())){
                wrapper.eq("sku_name", wmsWareOrderTaskDetail.getSkuName());
            }
                    if(wmsWareOrderTaskDetail.getSkuNum()!=null){
                    wrapper.gt("sku_num", wmsWareOrderTaskDetail.getSkuNum());
                    }
                    if(wmsWareOrderTaskDetail.getTaskId()!=null){
                    wrapper.gt("task_id", wmsWareOrderTaskDetail.getTaskId());
                    }
                    if(wmsWareOrderTaskDetail.getWareId()!=null){
                    wrapper.gt("ware_id", wmsWareOrderTaskDetail.getWareId());
                    }
                    if(wmsWareOrderTaskDetail.getLockStatus()!=null){
                    wrapper.gt("lock_status", wmsWareOrderTaskDetail.getLockStatus());
                    }
        }
        if(!ObjectUtils.isEmpty(queryVo.getStartTime())){
            wrapper.gt("create_time", queryVo.getStartTime());
        }
        if(!ObjectUtils.isEmpty(queryVo.getEndTime())){
            wrapper.lt("create_time", queryVo.getEndTime());
        }
        wrapper.orderByDesc("create_time");

        Page<WmsWareOrderTaskDetail> page = this.page(paramPage, wrapper);

        return page;
        }

       /* @Transactional(transactionManager = "transactionManagerXXX", rollbackFor = Exception.class)
        public boolean saveBatch(Collection<WmsWareOrderTaskDetail> entityList) {
        return saveBatch(entityList, DEFAULT_BATCH_SIZE);
        }
        */
}
